package com.AAA.service.Impl.mht;

import com.AAA.dao.mht.ITmhtRecordDedtailMapper;
import com.AAA.entity.mht.TMhtRecordDedtail;
import com.AAA.service.mht.ITmhtRecordDedtailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class TmhtRecordDedtailServiceImpl implements ITmhtRecordDedtailService {
    @Autowired
    private ITmhtRecordDedtailMapper mapper;
    @Override
    public boolean add(List<TMhtRecordDedtail> dedtails) {
        int i=0;
        for (TMhtRecordDedtail tm: dedtails
             ) {
            int insert = mapper.insert(tm);
            if (insert>0){
                i++;
            }
        }
        if (i==dedtails.size()){
            return true;
        }
        return false;
    }

    @Override
    public List<Map<String, Object>> getMhtResult(Integer id) {

        return mapper.getMhtResult(id);
    }

    @Override
    public boolean selectByTid(Integer tid) {
        TMhtRecordDedtail tMhtRecordDedtail = new TMhtRecordDedtail();
        tMhtRecordDedtail.setMhtno(tid);
        List<TMhtRecordDedtail> select = mapper.select(tMhtRecordDedtail);
        if (select.size()>0){
            return true;
        }
        return false;
    }
}
